#include <cmath>
#include <cstdio>

int prime[100001];
bool prime_mark[100001];
int prime_size;
void init_prime();

int main(int argc, char const* argv[])
{
    init_prime();
    int a, b;
    while (scanf("%d %d", &a, &b) != EOF) {
        if (a == -1 && b == -1)
            break;
        int result = 0;
        for (int i = a; i <= b; i++) {
            if (prime_mark[i])
                result++;
        }
        printf("%d\n", result);
    }
    return 0;
}

void init_prime()
{
    for (int i = 0; i < 100001; i++)
        prime_mark[i] = true;
    prime_mark[0] = false;
    prime_mark[1] = false;
    prime_size = 0;
    for (int i = 2; i < 100001; i++) {
        if (prime_mark[i] == false)
            continue;
        prime[prime_size++] = i;
        int bound = (int)sqrt(100000) + 1;
        if (i < bound) {
            for (int j = i * i; j <= 100000; j += i)
                prime_mark[j] = false;
        }
    }
}